﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BusinessLogicLayer;
using SQL_Provider;

namespace QL_HoSoBA
{
    public partial class frmLogin : DevComponents.DotNetBar.Office2007RibbonForm
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        public static TaiKhoan_Manager tk = new TaiKhoan_Manager();
        private MaHoa mh = new MaHoa();

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            DataTable reader = tk.TaiKhoanDN_TimTheoTenTK(txtTaiKhoan.Text, mh.MD5Format(txtMatKhau.Text));
            //DataTable reader = tk.TaiKhoanDN_TimTheoTenTK("bs01", "123456");
            if (reader.Rows.Count > 0)
            {
                MessageBox.Show("Cảm ơn, " + txtTaiKhoan.Text + " đã đăng nhập thành công !", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                frmHeThong.taikhoan = reader.Rows[0][0].ToString();
                frmHeThong.matkhau = reader.Rows[0][1].ToString();
                frmHeThong.chucvu = reader.Rows[0][4].ToString();
                frmHeThong.manv = reader.Rows[0][2].ToString();
                frmHeThong.tennv = reader.Rows[0][3].ToString();
                this.Close();
            }
            else
    MessageBox.Show("Bạn khai báo sai [tài khoản] hoặc [mật khẩu] !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        private void llblQuenMatKhau_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
               
                    frmTaiKhoan frm = new frmTaiKhoan();
                    frm.ShowForm(2);
                    frm.Show();
                
            }
            catch
            {
            }
        
            
          
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
